package com.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mapper.auto.SchoolV2Mapper;
import com.model.auto.SchoolV2;
import com.service.ISchoolV2Service;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * 新高考学校服务实现类
 *
 * @author zhaoyifan
 * @date 2023-09-22
 */
@Service
public class SchoolV2ServiceImpl extends ServiceImpl<SchoolV2Mapper, SchoolV2> implements ISchoolV2Service {

    @Override
    public SchoolV2 queryByParams(Integer majorType, String batch, String schoolCode, String groupCode) {
        List<SchoolV2> list = this.list(new LambdaQueryWrapper<SchoolV2>()
                .eq(SchoolV2::getType, majorType)
                .eq(SchoolV2::getBatch, batch)
                .eq(SchoolV2::getCode, schoolCode)
                .eq(SchoolV2::getGroupCode, groupCode)
        );

        if(Objects.nonNull(list) && list.size()>0){
            return list.get(0);
        }
        return null;
    }
}
